package org.battery.service;

import org.apache.commons.collections.map.HashedMap;
import org.battery.entity.Battery;
import org.battery.entity.Page;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by 1t on 2017-08-16.
 */
@Service("batteryService")
public class BatteryService extends BaseService{

//    public String getName()
//    {
//        return "1号电池";
//    }
    public List<Battery> getBattery(Battery battery, Page page) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("info", battery);
        map.put("page", page);
        return (List<Battery>) this.getDaoSupport().findForList("T_Battery.getBatteryPage", map);
    }

    public List<Battery> getBatteryTime() throws Exception {
        return (List<Battery>) this.getDaoSupport().findForList("T_Battery.getBatteryTime");
    }

    public List<Battery> getBatteryDay(Battery battery) throws Exception {
        return (List<Battery>) this.getDaoSupport().findForList("T_Battery.getBatteryDay", battery);
    }

    public List<Battery> getBatteryName(Battery battery) throws Exception {
        return (List<Battery>) this.getDaoSupport().findForList("T_Battery.getBatteryName", battery);
    }

    public int insertBattery(Battery battery) throws Exception {
        return (int)this.getDaoSupport().save("T_Battery.insertBattery", battery);
    }

    public int updateBattery(Battery battery) throws Exception {
        return (int) this.getDaoSupport().update("T_Battery.updateBattery", battery);
    }

    public int deleteBattery(Battery battery) throws Exception {
        return (int) this.getDaoSupport().delete("T_Battery.deleteBattery", battery);
    }

}
